﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LambdaInvoke
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Thread2OpreateMainUI TRD = new Thread2OpreateMainUI();
            TRD.DE = AppendTextInRichbox;
            new Thread(TRD.justForshow).Start();
        }

        private void AppendTextInRichbox(string toShow)
        {
            this.Invoke((Action<string>)(Promt =>
            {
                richTextBox1.AppendText(Promt);
                richTextBox1.ScrollToCaret();
            }), toShow);
        }
        //analyse:
        //first the code below is delegate and also it is an  anonymous method.
        //      (Promt =>
        //    {
        //        richTextBox1.AppendText(Promt);
        //        richTextBox1.ScrollToCaret();
        //    })
        // this method is mean to add the string to the end of the richbox
        // even in another thread 

    }
}
